/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * APropos.java
 *
 * Created on 22 juin 2009, 23:13:33
 */

package caylus.GUI;

import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Mouna
 */
public class AideDuJeu extends javax.swing.JDialog {

    /** Creates new form APropos */
    public AideDuJeu(java.awt.Frame parent, boolean modal) {
        super (parent, true);
        initComponents();
        centrerFenetre();
        repaint();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel2 = new javax.swing.JPanel();
        jTabbedPaneAideDuJeu = new javax.swing.JTabbedPane();
        jPanelAidePhase1 = new javax.swing.JPanel();
        jLabelHelp1 = new javax.swing.JLabel();
        jPanelAidePhase22 = new javax.swing.JPanel();
        jPanelAidePhase2 = new javax.swing.JScrollPane();
        jLabel1 = new javax.swing.JLabel();
        jPanelAidePhase33 = new javax.swing.JPanel();
        jPanelAidePhase3 = new javax.swing.JScrollPane();
        jLabel2 = new javax.swing.JLabel();
        jPanelAidePhase44 = new javax.swing.JPanel();
        jPanelAidePhase4 = new javax.swing.JScrollPane();
        jLabel3 = new javax.swing.JLabel();
        jPanelAidePhase5 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jLabel4 = new javax.swing.JLabel();
        jPanelAidePhase6 = new javax.swing.JPanel();
        jScrollPane5 = new javax.swing.JScrollPane();
        jLabel5 = new javax.swing.JLabel();
        jPanelAidePhase7 = new javax.swing.JPanel();
        jScrollPane6 = new javax.swing.JScrollPane();
        jLabel6 = new javax.swing.JLabel();
        jLabelPhaseExemple = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();

        setTitle("Règles du jeu");
        setResizable(false);

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jTabbedPaneAideDuJeu.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPaneAideDuJeuMouseClicked(evt);
            }
        });

        jLabelHelp1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/aideJeu1.png"))); // NOI18N

        javax.swing.GroupLayout jPanelAidePhase1Layout = new javax.swing.GroupLayout(jPanelAidePhase1);
        jPanelAidePhase1.setLayout(jPanelAidePhase1Layout);
        jPanelAidePhase1Layout.setHorizontalGroup(
            jPanelAidePhase1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAidePhase1Layout.createSequentialGroup()
                .addComponent(jLabelHelp1)
                .addContainerGap(23, Short.MAX_VALUE))
        );
        jPanelAidePhase1Layout.setVerticalGroup(
            jPanelAidePhase1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabelHelp1, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
        );

        jTabbedPaneAideDuJeu.addTab("Phase 1", jPanelAidePhase1);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/aideJeu2.png"))); // NOI18N
        jPanelAidePhase2.setViewportView(jLabel1);

        javax.swing.GroupLayout jPanelAidePhase22Layout = new javax.swing.GroupLayout(jPanelAidePhase22);
        jPanelAidePhase22.setLayout(jPanelAidePhase22Layout);
        jPanelAidePhase22Layout.setHorizontalGroup(
            jPanelAidePhase22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAidePhase22Layout.createSequentialGroup()
                .addComponent(jPanelAidePhase2, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelAidePhase22Layout.setVerticalGroup(
            jPanelAidePhase22Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAidePhase22Layout.createSequentialGroup()
                .addComponent(jPanelAidePhase2, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTabbedPaneAideDuJeu.addTab("Phase 2", jPanelAidePhase22);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/aideJeu3.png"))); // NOI18N
        jPanelAidePhase3.setViewportView(jLabel2);

        javax.swing.GroupLayout jPanelAidePhase33Layout = new javax.swing.GroupLayout(jPanelAidePhase33);
        jPanelAidePhase33.setLayout(jPanelAidePhase33Layout);
        jPanelAidePhase33Layout.setHorizontalGroup(
            jPanelAidePhase33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAidePhase33Layout.createSequentialGroup()
                .addComponent(jPanelAidePhase3, javax.swing.GroupLayout.PREFERRED_SIZE, 494, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelAidePhase33Layout.setVerticalGroup(
            jPanelAidePhase33Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelAidePhase3, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
        );

        jTabbedPaneAideDuJeu.addTab("Phase 3", jPanelAidePhase33);

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/aideJeu4.png"))); // NOI18N
        jPanelAidePhase4.setViewportView(jLabel3);

        javax.swing.GroupLayout jPanelAidePhase44Layout = new javax.swing.GroupLayout(jPanelAidePhase44);
        jPanelAidePhase44.setLayout(jPanelAidePhase44Layout);
        jPanelAidePhase44Layout.setHorizontalGroup(
            jPanelAidePhase44Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAidePhase44Layout.createSequentialGroup()
                .addComponent(jPanelAidePhase4, javax.swing.GroupLayout.PREFERRED_SIZE, 493, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelAidePhase44Layout.setVerticalGroup(
            jPanelAidePhase44Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanelAidePhase4, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
        );

        jTabbedPaneAideDuJeu.addTab("Phase 4", jPanelAidePhase44);

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/aideJeu5.png"))); // NOI18N
        jScrollPane4.setViewportView(jLabel4);

        javax.swing.GroupLayout jPanelAidePhase5Layout = new javax.swing.GroupLayout(jPanelAidePhase5);
        jPanelAidePhase5.setLayout(jPanelAidePhase5Layout);
        jPanelAidePhase5Layout.setHorizontalGroup(
            jPanelAidePhase5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAidePhase5Layout.createSequentialGroup()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 491, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelAidePhase5Layout.setVerticalGroup(
            jPanelAidePhase5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
        );

        jTabbedPaneAideDuJeu.addTab("Phase 5", jPanelAidePhase5);

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/aideJeu6.png"))); // NOI18N
        jScrollPane5.setViewportView(jLabel5);

        javax.swing.GroupLayout jPanelAidePhase6Layout = new javax.swing.GroupLayout(jPanelAidePhase6);
        jPanelAidePhase6.setLayout(jPanelAidePhase6Layout);
        jPanelAidePhase6Layout.setHorizontalGroup(
            jPanelAidePhase6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAidePhase6Layout.createSequentialGroup()
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 491, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelAidePhase6Layout.setVerticalGroup(
            jPanelAidePhase6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
        );

        jTabbedPaneAideDuJeu.addTab("Phase 6", jPanelAidePhase6);

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/aideJeu7.png"))); // NOI18N
        jScrollPane6.setViewportView(jLabel6);

        javax.swing.GroupLayout jPanelAidePhase7Layout = new javax.swing.GroupLayout(jPanelAidePhase7);
        jPanelAidePhase7.setLayout(jPanelAidePhase7Layout);
        jPanelAidePhase7Layout.setHorizontalGroup(
            jPanelAidePhase7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanelAidePhase7Layout.createSequentialGroup()
                .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 492, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanelAidePhase7Layout.setVerticalGroup(
            jPanelAidePhase7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane6, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
        );

        jTabbedPaneAideDuJeu.addTab("Phase 7", jPanelAidePhase7);

        jLabelPhaseExemple.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/phase1.png"))); // NOI18N

        jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/aideEnPDF.png"))); // NOI18N
        jLabel8.setToolTipText("Le fichier PDF sera lancer dans votre navigateur web.");
        jLabel8.setFocusable(false);
        jLabel8.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel8MouseClicked(evt);
            }
        });

        jLabel7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/caylus_button_ok.png"))); // NOI18N
        jLabel7.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel7MouseClicked(evt);
            }
        });

        jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/copyRight.png"))); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jTabbedPaneAideDuJeu, javax.swing.GroupLayout.PREFERRED_SIZE, 500, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabelPhaseExemple))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(295, 295, 295)
                        .addComponent(jLabel8)
                        .addGap(79, 79, 79)
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 229, Short.MAX_VALUE)
                        .addComponent(jLabel9)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPaneAideDuJeu, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel8)
                    .addComponent(jLabel7)))
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jLabelPhaseExemple)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 83, Short.MAX_VALUE)
                .addComponent(jLabel9)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 328, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jTabbedPaneAideDuJeuMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPaneAideDuJeuMouseClicked
        if (jTabbedPaneAideDuJeu.getSelectedComponent().equals(jPanelAidePhase1))
            jLabelPhaseExemple.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/phase1.png")));
        else if (jTabbedPaneAideDuJeu.getSelectedComponent().equals(jPanelAidePhase22))
                jLabelPhaseExemple.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/phase2.png")));
        else if (jTabbedPaneAideDuJeu.getSelectedComponent().equals(jPanelAidePhase33))
                jLabelPhaseExemple.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/phase3.png")));
        else if (jTabbedPaneAideDuJeu.getSelectedComponent().equals(jPanelAidePhase44))
                jLabelPhaseExemple.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/phase4.png")));
        else if (jTabbedPaneAideDuJeu.getSelectedComponent().equals(jPanelAidePhase5))
                jLabelPhaseExemple.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/phase5.png")));
        else if (jTabbedPaneAideDuJeu.getSelectedComponent().equals(jPanelAidePhase6))
                jLabelPhaseExemple.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/phase6.png")));
        else if (jTabbedPaneAideDuJeu.getSelectedComponent().equals(jPanelAidePhase7))
                jLabelPhaseExemple.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/aideDuJeu/phase7.png")));
    }//GEN-LAST:event_jTabbedPaneAideDuJeuMouseClicked

    private void jLabel7MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel7MouseClicked
        dispose();
    }//GEN-LAST:event_jLabel7MouseClicked

    private void jLabel8MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel8MouseClicked
            AideDuJeuWeb helpPDF = new AideDuJeuWeb();
            try {
                helpPDF.displayURL("http://www.ystari.com/caylus/adjF.pdf");
            } catch (IOException ex) {
                Logger.getLogger(AideDuJeu.class.getName()).log(Level.SEVERE, null, ex);
            }

    }//GEN-LAST:event_jLabel8MouseClicked

    private void centrerFenetre()
    {
        // on place notre fenêtre au milieu
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((screen.width - getSize().width)/2,(screen.height - getSize().height)/2);
    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabelHelp1;
    private javax.swing.JLabel jLabelPhaseExemple;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanelAidePhase1;
    private javax.swing.JScrollPane jPanelAidePhase2;
    private javax.swing.JPanel jPanelAidePhase22;
    private javax.swing.JScrollPane jPanelAidePhase3;
    private javax.swing.JPanel jPanelAidePhase33;
    private javax.swing.JScrollPane jPanelAidePhase4;
    private javax.swing.JPanel jPanelAidePhase44;
    private javax.swing.JPanel jPanelAidePhase5;
    private javax.swing.JPanel jPanelAidePhase6;
    private javax.swing.JPanel jPanelAidePhase7;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JTabbedPane jTabbedPaneAideDuJeu;
    // End of variables declaration//GEN-END:variables

      public class AideDuJeuWeb{
                /**
                 * Display a file in the system browser.  If you want to display a
                 * file, you must include the absolute path name.
                 *
                 * @param url the file's url (the url must start with either "http://"
            or
                 * "file://").
                 */
                public  void displayURL(String url) throws IOException
                {
                    boolean windows = isWindowsPlatform();
                    String cmd = null;
                    try
                    {
                        if (windows)
                        {
                            // cmd = 'rundll32 url.dll,FileProtocolHandler http://...'
                            cmd = WIN_PATH + " " + WIN_FLAG + " " + url;
                            Process p = Runtime.getRuntime().exec(cmd);
                        }
                        else
                        {
                            // Under Unix, Netscape has to be running for the "-remote"
                            // command to work.  So, we try sending the command and
                            // check for an exit value.  If the exit command is 0,
                            // it worked, otherwise we need to start the browser.
                            // cmd = 'netscape -remote openURL(http://www.javaworld.com)'
                            cmd = UNIX_PATH + " " + UNIX_FLAG + "(" + url + ")";
                            Process p = Runtime.getRuntime().exec(cmd);
                            try
                            {
                                // wait for exit code -- if it's 0, command worked,
                                // otherwise we need to start the browser up.
                                int exitCode = p.waitFor();
                                if (exitCode != 0)
                                {
                                    // Command failed, start up the browser
                                    // cmd = 'netscape http://www.javaworld.com'
                                    cmd = UNIX_PATH + " "  + url;
                                    p = Runtime.getRuntime().exec(cmd);
                                }
                            }
                            catch(InterruptedException x)
                            {
                                System.err.println("Error bringing up browser, cmd='" +
                                                   cmd + "'");
                                System.err.println("Caught: " + x);
                            }
                        }
                    }
                    catch(IOException x)
                    {
                        // couldn't exec browser
                        System.err.println("Could not invoke browser, command=" + cmd);
                        System.err.println("Caught: " + x);
                    }
                }
                /**
                 * Try to determine whether this application is running under Windows
                 * or some other platform by examing the "os.name" property.
                 *
                 * @return true if this application is running under a Windows OS
                 */
                public  boolean isWindowsPlatform()
                {
                    String os = System.getProperty("os.name");
                    if ( os != null && os.startsWith(WIN_ID))
                        return true;
                    else
                        return false;
                }
                /**
                 * Simple example.
                 */
               /* public static void main(String[] args) throws IOException
                {
                    displayURL("http://www.javaworld.com");
                }*/
                // Used to identify the windows platform.
                private static final String WIN_ID = "Windows";
                // The default system browser under windows.
                private static final String WIN_PATH = "rundll32";
                // The flag to display a url.
                private static final String WIN_FLAG = "url.dll,FileProtocolHandler";
                // The default browser under unix.
                private static final String UNIX_PATH = "netscape";
                // The flag to display a url.
                private static final String UNIX_FLAG = "-remote openURL";
            }

}
